package com.atlassian.jira.resource;

import java.util.ArrayList;
import java.util.Collection;
import java.util.Iterator;
import java.util.List;

import javax.xml.bind.annotation.XmlRootElement;

@XmlRootElement(name = "user")
public class DefaultUser implements User{

	private String username;
	private String fullname;
	private String email;
	private Collection<String> groupNames;

	public DefaultUser() {
	}

	public DefaultUser(com.opensymphony.user.User user) {
		
		this.groupNames = new ArrayList<String>();
		List<?> groups = user.getGroups();
		if (groups == null) {
			groups = new ArrayList<com.opensymphony.user.Group>();
		}
		
		for (Iterator<?> i = groups.iterator(); i.hasNext();) {
			com.opensymphony.user.Group group = (com.opensymphony.user.Group) i.next();
			this.groupNames.add(group.getName());
		}
	}

	public String getUsername() {
		return username;
	}

	public void setUsername(String username) {
		this.username = username;
	}

	public String getFullname() {
		return fullname;
	}

	public void setFullname(String fullname) {
		this.fullname = fullname;
	}

	public String getEmail() {
		return email;
	}

	public void setEmail(String email) {
		this.email = email;
	}

	public Collection<String> getGroupNames() {
		return groupNames;
	}

	public void setGroupNames(Collection<String> groupNames) {
		this.groupNames = groupNames;
	}

}
